﻿using AutoMapper;
using BW.MesProject.BasicData.Domain.Dto;
using BW.MesProject.BasicData.Domain.基础;
using BW.MesProject.BasicData.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace BW.MesProject.BasicData.Host.Controllers
{
    /// <summary>
    /// 工位管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkstationManagController : ControllerBase
    {
        private readonly IWorkstationManagServices workstationManagServices;

        public WorkstationManagController(IWorkstationManagServices workstationManagServices)
        {
            this.workstationManagServices = workstationManagServices;
        }
        /// <summary>
        /// 添加工位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddWorkstation(WorkstationManagement model)
        {
          return workstationManagServices.AddWorkstation(model);
        }
        /// <summary>
        /// 删除工位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> DeleteWorkstation(long id)
        {
           return workstationManagServices.DeleteWorkstation(id);
        }
        /// <summary>
        /// 获取工位
        /// </summary>
        /// <param name="input"></param>
        /// <param name="Workstationcode"></param>
        /// <param name="Workstationname"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<List<WorkstationDto>> GetWorkstation(int pageindex, int pagesize, string? Workstationcode, string? Workstationname)
        {
           return workstationManagServices.GetWorkstation(pageindex, pagesize, Workstationcode,Workstationname);
        }
        /// <summary>
        /// 获取所有工位
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<WorkstationManagement>> GetWorkstationBy()
        {
         return workstationManagServices.GetWorkstationBy();
        }
        /// <summary>
        /// 修改工位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateWorkstation(WorkstationManagement model)
        {
         return workstationManagServices.UpdateWorkstation(model);
        }
        /// <summary>
        /// 根据ID获取工位信息
        /// </summary>
        /// <param name="id">工位ID</param>
        /// <returns>工位信息</returns>
        [HttpGet]
        public ApiResult<WorkstationManagement> GetWorkstationById(long id)
        {
          return workstationManagServices.GetWorkstationById(id);
        }
    }
}
